
Public Class SystemMenu

    Protected _system_menu_id As Integer
    Protected _system_menu_name_tha As String
    Protected _system_menu_name_eng As String
    Protected _system_parent_menu_id As Integer
    Protected _system_menu_form As String
    Protected _system_menu_tab As String
    Protected _Data As ArrayList
    Protected _DataCurrent As Integer

    Public Property system_menu_id() As Integer
        Get
            Return _system_menu_id
        End Get
        Set(ByVal value As Integer)
            _system_menu_id = value
        End Set
    End Property

    Public Property system_menu_name_tha() As String
        Get
            Return _system_menu_name_tha
        End Get
        Set(ByVal value As String)
            _system_menu_name_tha = value
        End Set
    End Property

    Public Property system_menu_name_eng() As String
        Get
            Return _system_menu_name_eng
        End Get
        Set(ByVal value As String)
            _system_menu_name_eng = value
        End Set
    End Property

    Public Property system_parent_menu_id() As Integer
        Get
            Return _system_parent_menu_id
        End Get
        Set(ByVal value As Integer)
            _system_parent_menu_id = value
        End Set
    End Property

    Public Property system_menu_form() As String
        Get
            Return _system_menu_form
        End Get
        Set(ByVal value As String)
            _system_menu_form = value
        End Set
    End Property

    Public Property system_menu_tab() As String
        Get
            Return _system_menu_tab
        End Get
        Set(ByVal value As String)
            _system_menu_tab = value
        End Set
    End Property

    Public Function getSystemMenu() As DataSet
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_SystemMenu"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "SystemMenu")

        Return objDs
    End Function

    Protected Function getsSystemMenu() As ArrayList
        Dim outResult As New ArrayList()
        Dim decryptText As New DateUtilities.Encrypt_Data()
        Dim objConn As New MySql.Data.MySqlClient.MySqlConnection( _
            decryptText.getDecrypt(System.Configuration.ConfigurationManager.ConnectionStrings( _
            "PoliceHealthConnectionString").ToString(), True))
        Dim objCmd As New MySql.Data.MySqlClient.MySqlCommand()
        objCmd.Connection = objConn
        objCmd.CommandType = CommandType.StoredProcedure
        objCmd.CommandText = "proc_SELECT_SystemMenu"

        Dim objDa As New MySql.Data.MySqlClient.MySqlDataAdapter(objCmd)
        Dim objDs As New System.Data.DataSet()
        objDa.Fill(objDs, "SystemMenu")

        For Each objDr As System.Data.DataRow In objDs.Tables("SystemMenu").Rows
            Dim obj As SystemMenu = New SystemMenu()
            obj.system_menu_id = objDr.Item("system_menu_id").ToString()
            obj.system_menu_name_tha = objDr.Item("system_menu_name_tha").ToString()
            obj.system_menu_name_eng = objDr.Item("system_menu_name_eng").ToString()
            obj.system_parent_menu_id = objDr.Item("system_parent_menu_id").ToString()
            obj.system_menu_form = objDr.Item("system_menu_form").ToString()
            obj.system_menu_tab = objDr.Item("system_menu_tab").ToString()
            outResult.Add(obj)
        Next

        Return outResult
    End Function

    Public Sub LoadSystemMenu()
        _Data = New ArrayList
        _DataCurrent = 0
        _Data = getsSystemMenu()
    End Sub

    Public Overloads Function NextRecord() As Boolean
        If ((Not _Data Is Nothing) AndAlso (((Not _Data Is Nothing) AndAlso _
            (_DataCurrent < _Data.Count And _Data.Count > 0)))) Then
            _system_menu_id = _Data(_DataCurrent).system_menu_id
            _system_menu_name_tha = _Data(_DataCurrent).system_menu_name_tha
            _system_menu_name_eng = _Data(_DataCurrent).system_menu_name_eng
            _system_parent_menu_id = _Data(_DataCurrent).system_parent_menu_id
            _system_menu_form = _Data(_DataCurrent).system_menu_form
            _system_menu_tab = _Data(_DataCurrent).system_menu_tab

            _DataCurrent += 1
            Return True
        End If
        Return False
    End Function

End Class
